#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int n, l, r;

int main (void)
{
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout);
	scanf("%d %d %d", &n, &l, &r);
	if (r - l + 1 >= n)
		printf("%d", n - 1);
	else if (r % n < l % n) 
		printf("%d", n - 1);
	else 
		printf("%d", r % n);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
